﻿Imports System.Data.SqlClient
Imports QuanLyBanChau.LoaiKhachHangdto

Public Class LoaiKhachHang_dao


    Public Shared Sub insertLoaiKhachHangdao(ByVal LoaiKhachHang As LoaiKhachHangdto)
        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim para(7) As SqlParameter
        conn = dataprovider.Connection()
        cmd = New SqlCommand("insert_LoaiKhachHang", conn)
        cmd.CommandType = CommandType.StoredProcedure
        para(0) = New SqlParameter(" @Maloaikhachhang", SqlDbType.VarChar, 10)
        para(0).Value = LoaiKhachHang.Maloaikhachhang
        cmd.Parameters.Add(para(0))
        para(1) = New SqlParameter(" @Ten", SqlDbType.NVarChar, 10)
        para(1).Value = LoaiKhachHang.Ten
        cmd.Parameters.Add(para(1))


        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
    End Sub


    Public Shared Sub DeleteLoaiKhachHangdao(ByVal Maloaikhachhang)
        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim para(1) As SqlParameter
        conn = dataprovider.Connection()
        cmd = New SqlCommand("Delete_LoaiKhachHang", conn)
        cmd.CommandType = CommandType.StoredProcedure
        para(1) = New SqlParameter(" @Maloaikhachhang", SqlDbType.VarChar, 10)
        para(1).Value = Maloaikhachhang
        cmd.Parameters.Add(para(1))
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
    End Sub
    Public Shared Function Get_LoaiKhachHangdao()
        Dim conn As SqlConnection
        conn = dataprovider.Connection()
        Dim da As New SqlDataAdapter
        Dim dt As New DataTable
        da.SelectCommand = New SqlCommand
        da.SelectCommand.Connection = conn
        da.SelectCommand.CommandType = CommandType.StoredProcedure
        da.SelectCommand.CommandText = "Get_LoaiKhachHang"
        da.Fill(dt)
        Return dt
    End Function

    Public Shared Sub UpdateLoaiKhachHangdao(ByVal LoaiKhachHang As LoaiKhachHangdto)
        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim para(7) As SqlParameter
        conn = dataprovider.Connection()
        cmd = New SqlCommand("Update_LoaiKhachHang", conn)
        cmd.CommandType = CommandType.StoredProcedure
        para(0) = New SqlParameter(" @Maloaikhachhang", SqlDbType.VarChar, 10)
        para(0).Value = LoaiKhachHang.Maloaikhachhang
        cmd.Parameters.Add(para(0))
        para(1) = New SqlParameter(" @Ten", SqlDbType.NVarChar, 10)
        para(1).Value = LoaiKhachHang.Ten
        cmd.Parameters.Add(para(1))


        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
    End Sub


End Class
